Telegram Group & Telegram Channel
⚡️ Фича дня: условный оператор с инициализацией

Часто перед условным оператором нужно объявить временную переменную, что загромождает область видимости и увеличивает вероятность ошибок.

Инициализация переменных прямо в условии if/switch (C++17) позволяет ограничить область видимости только блоком условия.

🔴 До:
auto it = map.find(key);
if (it != map.end()) {
// Используем it->second
}


🟢 После:
if (auto it = map.find(key); it != map.end()) {
// Используем it->second
}


Примеры использования:

- Поиск в контейнерах с проверкой результата
- Вызов функций с проверкой возвращаемого значения
- Инициализация мьютексов с последующей блокировкой

💡 Как думаете, улучшает ли это читаемость кода?

Библиотека C/C++ разработчика #буст



tg-me.com/cppproglib/5674
Create:
Last Update:

⚡️ Фича дня: условный оператор с инициализацией

Часто перед условным оператором нужно объявить временную переменную, что загромождает область видимости и увеличивает вероятность ошибок.

Инициализация переменных прямо в условии if/switch (C++17) позволяет ограничить область видимости только блоком условия.

🔴 До:

auto it = map.find(key);
if (it != map.end()) {
// Используем it->second
}


🟢 После:
if (auto it = map.find(key); it != map.end()) {
// Используем it->second
}


Примеры использования:

- Поиск в контейнерах с проверкой результата
- Вызов функций с проверкой возвращаемого значения
- Инициализация мьютексов с последующей блокировкой

💡 Как думаете, улучшает ли это читаемость кода?

Библиотека C/C++ разработчика #буст

BY Библиотека C/C++ разработчика | cpp, boost, qt


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/cppproglib/5674

View MORE
Open in Telegram


Библиотека C C разработчика | cpp boost qt Telegram | DID YOU KNOW?

Date: |

Telegram has exploded as a hub for cybercriminals looking to buy, sell and share stolen data and hacking tools, new research shows, as the messaging app emerges as an alternative to the dark web.An investigation by cyber intelligence group Cyberint, together with the Financial Times, found a ballooning network of hackers sharing data leaks on the popular messaging platform, sometimes in channels with tens of thousands of subscribers, lured by its ease of use and light-touch moderation.

At a time when the Indian stock market is peaking and has rallied immensely compared to global markets, there are companies that have not performed in the last 10 years. These are definitely a minor portion of the market considering there are hundreds of stocks that have turned multibagger since 2020. What went wrong with these stocks? Reasons vary from corporate governance, sectoral weakness, company specific and so on. But the more important question is, are these stocks worth buying?

Библиотека C C разработчика | cpp boost qt from ru


Telegram Библиотека C/C++ разработчика | cpp, boost, qt
FROM USA